<template>
  <div class="formDiv">
    <el-card class="box-card">
      <div class="back">
        <div>
          <el-button
            class="submission priamry_border"
            style="display: flex; float: right"
            @click="back"
            >返回</el-button
          >
        </div>
      </div>
      <el-form
        ref="ruleForm"
        :model="ruleForm"
        clearable
        label-width="102px"
        class="formArea"
      >
        <el-row>
          <el-col :span="12"
            ><div>
              <!-- 区域 -->
              <el-form-item label="区域:">
                <span v-html="ruleForm.region"> </span>
              </el-form-item></div
          ></el-col>
          <el-col :span="12"
            ><div>
              <!-- 店铺详细地址 -->
              <el-form-item label="店铺地址 :">
                <span v-html="ruleForm.address"> </span>
              </el-form-item></div
          ></el-col>
        </el-row>
        <el-divider></el-divider>
        <el-row>
          <el-col :span="12"
            ><div>
              <!-- 联系人 -->
              <el-form-item label="联系人：">
                <span v-html="ruleForm.contact"> </span>
              </el-form-item></div
          ></el-col>
          <el-col :span="12"
            ><div>
              <!-- 联系电话 -->
              <el-form-item label="联系电话：">
                <span v-html="ruleForm.phone"> </span>
              </el-form-item></div
          ></el-col>
        </el-row>
        <el-row>
          <el-col :span="12"
            ><div>
              <!-- 店铺介绍 -->
              <el-form-item label="店铺介绍：">
                <span v-html="ruleForm.introduce"> </span>
              </el-form-item></div
          ></el-col>
          <el-col :span="12"
            ><div>
              <!-- 备注 -->
              <el-form-item label="备注：">
                <span v-html="ruleForm.remark"> </span>
              </el-form-item></div
          ></el-col>
        </el-row>
        <el-divider></el-divider>
        <el-row>
          <el-col :span="12"
            ><div>
              <!-- 店铺名称 -->
              <el-form-item label="店铺名称:">
                <span v-html="ruleForm.shopName"> </span>
              </el-form-item></div
          ></el-col>
          <el-col :span="12"
            ><div>
              <!-- 评分 -->
              <el-form-item label="评分：">
                <span v-html="ruleForm.score"> </span>
              </el-form-item></div
          ></el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <div class="picUpload">
              <el-form-item label="店铺logo：">
                <div class="upLoadPicBox" :disabled="isDisabled">
                  <div v-if="ruleForm.shopLog" class="pictrue">
                    <img :src="ruleForm.shopLog" />
                  </div>
                </div>
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="12">
            <div class="picUpload">
              <el-form-item label="广告图片：">
                <div class="upLoadPicBox">
                  <div
                    v-for="(item, index) in ruleForm.advertises"
                    :key="index"
                    class="pictrue"
                    draggable="true"
                  >
                    <img :src="item" />
                  </div>
                </div>
              </el-form-item>
            </div>
          </el-col>
        </el-row>
        <el-divider></el-divider>
        <el-row>
          <el-col :span="12"
            ><div>
              <el-form-item class="buttons"> </el-form-item></div
          ></el-col>
          <el-col :span="12"><div></div></el-col>
        </el-row>
      </el-form>
    </el-card>
  </div>
</template>

<script>
import { seeShopApi } from "@/api/aishop";
export default {
  name: "shopDetail",
  created() {
    this.getShop(); //根据 id 查询店铺信息
  },
  data() {
    return {
      isDisabled: this.$route.params.isDisabled === "1" ? true : false,
      //表单
      ruleForm: {
        address: "", //店铺详细地址
        advertises: [], //广告图片
        collect: 0,
        contact: "", //联系人
        phone: "", //联系电话
        id: 0,
        introduce: "", //店铺介绍
        region: "", //区域
        remark: "", //备注
        shopLog: "", //店铺logo
        shopName: "", //店铺名称
      },
      //查询所有酒店
      hotalForm: {
        limit: 10,
        page: 1,
      },
    };
  },
  methods: {
    //根据 id 查询店铺信息
    async getShop() {
      const id = JSON.parse(sessionStorage.getItem("datathree"));
      const res = await seeShopApi({ id });
      if (res.city == null) {
        this.ruleForm.region = res.province + "";
      } else if (res.county == null) {
        this.ruleForm.region = res.province + res.city + "";
      } else {
        this.ruleForm.region = res.province + res.city + res.county + "";
      }
      this.ruleForm.address = res.address;
      this.ruleForm.contact = res.contact;
      this.ruleForm.remark = res.remark;
      this.ruleForm.shopName = res.shopName;
      this.ruleForm.shopLog = res.shopLog;
      this.ruleForm.introduce = res.introduce;
      this.ruleForm.phone = res.phone;
      this.ruleForm.advertises = res.advertises;
      this.ruleForm.score = res.score;
    },
    //返回上一页
    back() {
      this.$router.go(-1);
    },

    //取消按钮
    cancel() {
      this.$router.go(-1);
    },
  },
  watch: {
    $route: {
      handler() {
        this.getShop(); //根据 id 查询店铺信息
      },
    },
  },
};
</script>

<style lang="scss">
.formDiv {
  margin-top: 40px;
  margin-left: 30px;
  .back {
    width: 100%;
    height: 40px;
    display: flex;
    justify-content: end;
  }
  .formArea {
    padding: 0 30px;
    .picUpload {
      width: 800px;
      height: 100px;
      .upLoadPicBox {
        display: flex;
        width: 800px;
        height: 70px;
      }
    }
    .pictrue {
      width: 60px;
      height: 60px;
      border: 1px dotted rgba(0, 0, 0, 0.1);
      margin-right: 10px;
      position: relative;
      cursor: pointer;
    }
    .btndel {
      position: absolute;
      z-index: 1;
      width: 20px !important;
      height: 20px !important;
      left: 46px;
      top: -4px;
    }
  }
  .el-row {
    margin-bottom: 20px;
    &:last-child {
      margin-bottom: 0;
    }
  }
  .el-col {
    border-radius: 4px;
  }
  .grid-content {
    border-radius: 4px;
    min-height: 36px;
  }
  .bg-purple {
    background: #d3dce6;
  }
  .bg-purple-light {
    background: #e5e9f2;
  }
  .grid-content {
    border-radius: 4px;
    min-height: 36px;
  }

  .el-input__inner {
    width: 30vw;
  }
  .el-select .el-select--medium {
    width: 40vw;
  }
  .buttons {
    width: 100%;
    height: 50px;
  }
}
.upload {
  width: 80px;
  height: 80px;
  // display: flex;
  text-align: center;
  line-height: 80px;
  background-color: pink;
  border: 1px solid #fff;
}
</style>